﻿using System.Collections.Generic;
using System.Linq;
using FrameDesign.FrameWork;

namespace FrameDesign.Example3
{
    public class UserInfo
    {
        public string Name {get;set;}

        public int Age {get;set;}
  
        public string Id {get;set;}
    }
    public interface IUserModel : IModel
    {
        UserInfo GetUserInfoById(string id);
    }

    public class UserModel : AbstractModel, IUserModel
    {
        List<User> mUsers = new List<User>();
    
        protected override void OnInit()
        {
        }
    
        public UserInfo GetUserInfoById(string id)
        {
            return mUsers.Where(u=>u.Id == id).Select(u=> new UserInfo(){
                Name = u.Name,
                Age = u.Age,
                Id = u.Id,
            }).FirstOrDefault();
        }
    }
}